﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Linq;
using Tauren.Form.Infrastructure;
using Tauren.Form.Infrastructure.Common;
using Tauren.Form.Service.Form_TableInfoBLL;

namespace Tauren.Form.Core.Controllers.V2._0
{
    /// <summary>
    /// 表单表版本信息接口-v2.0
    /// </summary>
    [Route("api/formtable/v{version:apiVersion}"),ApiVersion("2.0")]
    [ApiController]
    public class Form_TableInfoController : ControllerBase
    {
        private IForm_TableInfoService service; 
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="service"></param>
        public Form_TableInfoController(IEnumerable<IForm_TableInfoService> services)
        {
            this.service = services.FirstOrDefault(o => o.VersionName == 2.0);
            if (this.service == null) throw new ApiVersionException("不支持当前版本");
        }
        /// <summary>
        /// 分页获取 单位信息列表
        /// </summary>
        /// <param name="queryModel"></param>
        /// <returns></returns>
        [HttpPost, Route("pages")]
        public IActionResult Pages([FromBody] Entity.Global.QueryModel queryModel) => service.Pages(queryModel).ToJsonResult(); 

    }
}
